package com.example.demo.mapper;

import com.example.demo.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface AdminMapper extends JpaRepository<User, String>, JpaSpecificationExecutor<User> {
    @Query(name="findUserById",nativeQuery = true,value="select * from user where id=:ID")
    User findUserById(String ID);
    @Query(name="findUserByPersonId",nativeQuery = true,value="select * from user where identityid=:identityId")
    User findUserByPersonid(String identityId);
    @Query(name="findUserByEmail",nativeQuery = true,value="select * from user where mail=:mail")
    List<User> findUserByEmail(String mail);
    @Query(name="findUserByMobile",nativeQuery = true,value="select * from user where phonenumber=:phoneNumber")
    List<User> findUserByMobile(String phoneNumber);

    @Query(name="findAllByRole", nativeQuery = true, value = "select * from user where role = :role")
    List<User> findAllByRole(String role);

}
